package com.ruoyi.client.controller;

import com.ruoyi.client.pojo.vo.StoreDetailVo;
import com.ruoyi.client.pojo.vo.StoreListVo;
import com.ruoyi.client.service.ClientStoreService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

@Anonymous // 允许匿名访问
@Api(tags = "2-店铺接口")
@RestController
@RequestMapping("/store")
public class ClientStoreController extends BaseController {

    @Resource
    private ClientStoreService clientStoreService;

    @ApiOperation(value = "获取店铺详情", notes = "根据店铺ID查询店铺详情")
    @GetMapping("/{storeId}")
    public R<StoreDetailVo> getStoreDetail(
            @PathVariable @ApiParam(value = "店铺ID", required = true) Long storeId) {
        StoreDetailVo detail = clientStoreService.getStoreDetail(storeId);
        return R.ok(detail);
    }

    @ApiOperation(value = "获取营业中店铺列表", notes = "查询所有状态为营业中的店铺列表")
    @GetMapping("/list")
    public R<List<StoreListVo>> getStoreList() {
        List<StoreListVo> list = clientStoreService.getStoreList();
        return R.ok(list);
    }
}